// 创建路由器并暴露
import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/Pages/Home.vue'
import News from '@/Pages/News.vue'
import Learn from '@/Pages/Learn.vue'
import Detail from '@/Pages/Detail.vue'
import Pinia from '@/Pages/Pinia.vue'
import OtherApi from '@/Pages/OtherApi.vue'
const router = createRouter({
  history: createWebHistory(), //工作模式
  routes: [
    {
      path: '/',
      redirect: '/home',
    },
    {
      name: 'zhuye',
      path: '/home',
      component: () => Home,
    },
    {
      name: 'xinwen',
      path: '/news',
      component: () => News,
      children: [
        {
          name: 'xiangqing',
          component: () => Detail,

          // query方式
          // path: 'detail',
          // props: (route) => {
          //   return route.query
          // },

          // params方式，需提前占位，加?是参数可选性
          path: 'detail/:title?/:content?',
          props: true,
        },
      ],
    },
    {
      name: 'xuexi',
      path: '/learn',
      component: () => Learn,
    },
    {
      name: 'zhuangtai',
      path: '/pinia',
      component: () => Pinia,
    },
    {
      name: 'qita',
      path: '/other',
      component: () => OtherApi,
    },
  ],
})
export default router
